package com.htfyun.eink.pw.draw.pen.epd.charcoal;


import com.htfyun.eink.pw.draw.pen.epd.EPDBaseManager;
import com.htfyun.eink.pw.draw.pen.epd.data.NeoRenderPoint;
import com.htfyun.eink.pw.draw.pointer.PWPointer;

import java.util.List;
import java.util.Map;

public class CharcoalManager extends EPDBaseManager {

    private final CharcoalParam param = new CharcoalParam(true, 2.0f);

    private final CharcoalPenImpl impl = new CharcoalPenImpl();

    @Override
    public void setStrokeWidth(float strokeWidth) {
        param.setStrokeWidth(strokeWidth);
    }

    @Override
    public void onDown(PWPointer point) {
        if (param.previousPoint == null) {
            param.previousPoint = new PWPointer();
        }
        param.previousPoint.configBy(point);
    }

    @Override
    public void onMove(PWPointer point) {
        if (param.previousPoint != null) {
            impl.strokeTo(param, point);
            param.previousPoint.configBy(point);
        } else {
            param.previousPoint = new PWPointer();
            param.previousPoint.configBy(point);
        }

    }

    @Override
    public void onUp(PWPointer point) {

    }

    public Map<Integer, BitmapData> getPointTableMap() {
        return impl.getPointTableMap();
    }

    public List<NeoRenderPoint> getRenderPoints() {
        return impl.getRenderPoints();
    }

    @Override
    public void clear() {
        getRenderPoints().clear();
        getPointTableMap().clear();
    }
}
